package com.heima.user.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.ApUserConstants;
import com.heima.model.user.dto.AuthDto;
import com.heima.model.user.entity.ApUserRealname;
import com.heima.user.service.ApUserRealnameService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * APP实名认证信息表(ApUserRealname)表控制层
 *
 * @author makejava
 * @since 2022-04-23 08:54:23
 */
@RestController
@RequestMapping(path = "/api/v1/auth")
public class ApUserRealnameController {
    /**
     * 服务对象
     */
    @Resource
    private ApUserRealnameService apUserRealnameService;

    /**
     * 提交用户实名认证信息
     * 参数名=参数值&参数名=参数值&参数名=参数值
     *
     * @return
     */
    @PostMapping(path = "/submit")
    public ResponseResult submit(MultipartFile font_image,
                                 MultipartFile back_image,
                                 MultipartFile hold_image,
                                 MultipartFile live_image,
                                 String name,
                                 String idno) {

        return apUserRealnameService.submit(font_image,back_image,hold_image,live_image,name,idno);
    }


    @PostMapping("/list")
    public ResponseResult loadListByStatus(@RequestBody AuthDto dto){
        return apUserRealnameService.loadListByStatus(dto);
    }

    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto ){
        return apUserRealnameService.updateStatus(dto, ApUserConstants.PASS_AUTH);
    }

    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto ){
        return apUserRealnameService.updateStatus(dto, ApUserConstants.FAIL_AUTH);
    }
}
